this.name      = "nukeSubmunition"; 
this.author    = "eric walch"; 
this.copyright = "� 2008 the autors.";
this.description = "Nuke script";
this.version   = "1.1";

// Some of the subs already collide with the target before any script can trigger.
this.shipDied = this.detonate = function()
{
	if(this.ship.target) 
	{
		if(this.ship.target.energy < 125) 
		{
			if(this.ship.owner) this.owner=this.ship.owner; // a bit complex to let it work in both 1.72 and 1.73+
			if(this.ship.target.bounty && this.owner.isPlayer)
			{
				player.consoleMessage("Bounty : "+this.ship.target.bounty+" cr.");
				player.consoleMessage("Total : "+Math.round(player.credits*10)/10+" cr.");
				player.credits += this.ship.target.bounty;
				player.score++;
			}
			this.ship.target.explode();
		}
		else this.ship.target.energy -= 125;
		// can't kill a ship by just setting energy low.
	}
	delete this.shipDied; // make sure it only triggers once.
}